
//PSim
//Message related function and structures

#ifndef MESSAGE_H
#define MESSAGE_H

#include <stdio.h>
#include <config.h>
#include <cpu.h>
#include <cpu-defs.h>

//Message Structures, which are passed betweeen devices
enum MessageType
{
  READ_MSG = 0,
  WRITE_MSG,
  INTERRUPT_MSG,
  NUM_MSG
};

static const char* MessageTypeNames[NUM_MSG] = {
  "READ_MSG",
  "WRITE_MSG",
  "INTERRUPT_MSG",
};

typedef struct Message Message;
struct Message 
{
  uint8_t type;
  void* from; //This are pointer to SimDevice but can be anything..
//  void* to;
  void* opaque; //This pointer is used by qemu functions
  uint64_t addr; //As interrupt message it shows interrupt no
  uint64_t data;
  int size;
};


Message* sim_new_write_msg(void* op, uint64_t addr, uint64_t data, int size);
Message* sim_new_read_msg(void* op, uint64_t addr, int size);
void init_messages();
void sim_delete_message(Message* msg);

#endif // MESSAGE_H
